
(function(){
	//回到今天
	var $today_back = DOMUtil.getElementsByClassName('today_back')[0];
	var $text = DOMUtil.getElementsByClassName('text', $today_back)[0];
	$text.onclick = function(){
		format();
	};



	//打开城市选择页面
	var $header = DOMUtil.getElementsByClassName('header')[0];
	var $city = DOMUtil.getElementsByClassName('city', $header)[0];
	var $select_city = DOMUtil.getElementsByClassName('select_city', $city)[0];
	$select_city.onclick = function(){
		//TODO 打开城市选择页面
		alert('这将打开城市选择页面');
	};
})();

//提醒页面
(function(){
	var $remind_closed_tip = DOMUtil.getElementsByClassName('remind_closed_tip')[0];
	var $remind_page = DOMUtil.getElementsByClassName('remind_page')[0];
	var $set_btn = DOMUtil.getElementsByClassName('set_btn', $remind_page)[0];
	var $close = DOMUtil.getElementsByClassName('close',$remind_page)[0];
	$close.onclick = function(e) {
		$remind_page.style.display = 'none';
	}

	var $set_remind = DOMUtil.getElementsByClassName('set_remind')[0];
	var $show = DOMUtil.getElementsByClassName('show', $set_remind)[0];
	$show.onclick = function() {
		var is_set = $set_remind.getAttribute('is_set');
		var project_id = $set_remind.getAttribute('project_id');
		if (is_set && is_set == 'yes') {
			$set_remind.setAttribute('is_set', 'no');
			$show.src = './image/remind_no.png';
			if ($remind_closed_tip) {
				$remind_closed_tip.style.display="block";
				setTimeout(function(){
					$remind_closed_tip.style.display="none";}
				,1000);
			}
		} else {
			if (project_id) {
				$remind_page.style.display = 'block';
				$set_btn.setAttribute('project_id', project_id);
			}
		}
	}

	$set_btn.onclick = function(e) {
		e = e || window.event;
		var target = e.target || e.srcElement;
		while(target.tagName!='DIV'){
			target = target.parentNode;
		}
		var project_id = target.getAttribute('project_id');
		if (project_id) {
			//TODO 发送设置请求
			alert('设置成功');
			$set_btn.setAttribute('project_id', '');
			$remind_page.style.display = 'none';
			$set_remind.setAttribute('is_set', 'yes');
			$show.src = './image/remind_yes.png';
		} else {
			alert('设置失败：无法确认当前楼盘');
		}
	}
})();
